package aconcagua.measure

import groovy.transform.ToString;

class BaseUnit extends SimpleUnit {
	private nameForOne;
	private nameForMany;
	private sign;

	// (class) instance creation
	public BaseUnit(aNameForOne) {
		constructorHelper(aNameForOne, nameForManyFrom(aNameForOne), defaultSign());
	}

	public BaseUnit(aNameForOne, aSign) {
		constructorHelper(aNameForOne, nameForManyFrom(aNameForOne), aSign);
	}

	public BaseUnit(aNameForOne, aNameForMany, aSign) {
		constructorHelper(aNameForOne, aNameForMany, aSign);
	}
	
	// instance creation - private
	private void constructorHelper(aNameForOne, aNameForMany, aSign) {
		nameForOne = aNameForOne;
		nameForMany = aNameForMany;
		sign = aSign;
	}

	// accessing
	@Override
	public baseUnit() {
		return this;
	}

	@Override
	public nameForMany() {
		return nameForMany;
	}

	@Override
	public nameForOne() {
		return nameForOne;
	}
	@Override
	public nothingAmount() {
		return 0;
	}

	@Override
	public sign() {
		return sign;
	}

	// converting
	@Override
	public convertAmountToBaseUnit(aNumber) {
		return aNumber;
	}

	// converting - private
	@Override
	protected convertFromBaseUnit(aMeasure) {
		return aMeasure;
	}

	protected convertToBaseUnit(aMeasure) {
		return aMeasure;
	}

	// testing
	public isZero() {
		return this.isNothing();
	}

	public sameDomainAs(aUnit) {
		return this.baseUnit() == aUnit.baseUnit();
	}
}
